package com.huaruan.youdi.adapter;

import android.content.Context;
import android.view.ViewGroup;
import android.widget.TextView;

import com.huaruan.youdi.R;
import com.huaruan.youdi.models.AppealModel;
import com.huaruan.youdi.views.widget.easyrecyclerview.adapter.BaseViewHolder;
import com.huaruan.youdi.views.widget.easyrecyclerview.adapter.RecyclerArrayAdapter;


public class AppealListAdapter extends RecyclerArrayAdapter<AppealModel> {
    Context context;

    public AppealListAdapter(Context context) {
        super(context);
        this.context = context;
    }

    @Override
    public BaseViewHolder OnCreateViewHolder(ViewGroup parent, int viewType) {
        return new ViewHolder(parent);
    }

    class ViewHolder extends BaseViewHolder<AppealModel> {
        TextView tv_code;
        TextView tv_date;
        TextView tv_send_name;
        TextView tv_send_phone;
        TextView tv_send_address;
        TextView tv_receive_name;
        TextView tv_receive_phone;
        TextView tv_receive_address;
        TextView tv_cause;
        TextView tv_price;

        public ViewHolder(ViewGroup itemView) {
            super(itemView, R.layout.item_appeal_list);
            this.tv_code = $(R.id.tv_code);
            this.tv_date = $(R.id.tv_date);
            this.tv_send_name = $(R.id.tv_send_name);
            this.tv_send_phone = $(R.id.tv_send_phone);
            this.tv_send_address = $(R.id.tv_send_address);
            this.tv_receive_name = $(R.id.tv_receive_name);
            this.tv_receive_phone = $(R.id.tv_receive_phone);
            this.tv_receive_address = $(R.id.tv_receive_address);
            this.tv_cause = $(R.id.tv_cause);
            this.tv_price = $(R.id.tv_price);
        }

        @Override
        public void setData(AppealModel model) {
            super.setData(model);
            tv_code.setText(model.timelyWaybill.tmNo);
            tv_date.setText(model.complaint.createTime);
            tv_send_name.setText(model.timelyWaybill.sender);
            tv_send_phone.setText(model.timelyWaybill.senderPhone);
            tv_send_address.setText(model.timelyWaybill.senderAddress);
            tv_receive_name.setText(model.timelyWaybill.receiver);
            tv_receive_phone.setText(model.timelyWaybill.receiverPhone);
            tv_receive_address.setText(model.timelyWaybill.receiverAddress);
            if ("0".equals(model.complaint.destroyCause)) {
                tv_cause.setText("销单原因: 业务员原因");
            } else if ("1".equals(model.complaint.destroyCause)) {
                tv_cause.setText("销单原因: 客户自身原因");
            } else if ("2".equals(model.complaint.destroyCause)) {
                tv_cause.setText("销单原因: 天气原因");
            } else if ("3".equals(model.complaint.destroyCause)) {
                tv_cause.setText("销单原因: 其他原因");
            }
            tv_price.setText(model.timelyWaybill.amount);
        }
    }
}
